Technical Q&A
SND 08 - Playing Compressed WAVE files via the Sound Manager
(27-September-96)
Q Can I play a compressed WAVE file on the Mac?
A Yes, but probably not with the default functionality
of the Sound Manager.
You have to do all of the sound header parsing yourself, just as
you do for an uncompressed sound, and then you have data which you
may or may not be able to directly pass to the Sound Manager.
If the WAVE is formatted using µlaw then your program doesn't
have to do anything special. Since the µlaw file is processed on
a byte by byte, and there is no endian difference between the same
data as an AIFF or WAVE file, the standard Mac µlaw decompressor
can deal with this data without a problem.
On the other hand, you cannot play IMA-ADPCM compressed WAVE files
as simply as you could play a µlaw WAVE files because of the
difference in the actual data stream of a sound compressed with the
Mac's IMA compressor versus the same sound compressed with the
Windows' IMA-ADPCM compressor.
You have to deal with Windows' IMA-ADPCM compressed WAVE sounds
just as you would any sound which required a custom decompressor.
Your program does all the decompression. This can be done either by
writing a decompression component for the Mac (in which case any
program can use it), or by having a decompression function in your
program.
If you write your own 'sdec' then you can use any Sound Manager
routine that will play an arbitrarily compressed sound, just make
sure to say that the sound header says the sound is compressed with
your compressor so that the Sound Manager will call your 'sdec'.
If you choose not to write a decompression component and you can
decompress the sound completely, then you can use any Sound Manager
call that takes a buffer of uncompressed sound. If you can't decompress the
sound completely then you will have to decompress it in chunks and use
SndPlayDoubleBuffer or bufferCmd's to play each chunk.
Technical Q&A
Previous Question |
Contents |
Next Question
|